<?php
namespace app\admin\controller;
use app\admin\model\Dingdan as DingdanModel;
use app\admin\model\Kehu as KehuModel;
use WeChatPay\Builder;
use WeChatPay\Crypto\Rsa;
use WeChatPay\Util\PemUtil;
use WeChatPay\Formatter;
use WeChatPay\Crypto\AesGcm;
/**
 * Created by PhpStorm.
 * User: tanhuaxin
 * Date: 2019/3/13
 * Time: 下午10:54
 */
class Index extends Controller
{

    /**
     * layout
     * @return \think\response\View
     */
    function index()
    {
		 return view('index');
    }

    /**
     * 后台主页
     */
    function home()
    {
        $zdds = 123;
        $xdsl = 2344;
        $cksl = 2;
        $khs = 3444;
        return $this->fetch('home', compact('zdds', 'khs', 'xdsl', 'cksl'));
    }

      /**
     * 上传
     * @return array
     */
    function upload()
    {
        $file = request()->file('file');
        $path = ROOT_PATH . 'public' . DS . 'static/uploads/';
        $info = $file->validate(['ext'=>'jpeg,jpg,png,gif'])->move( $path);
        if($info){
            $n = $info->getSaveName();
            $n = str_replace('\\', '\/', $n );
            return $this->renderSuccess('上传成功', '', '/uploads\/'.$n);
        }
        return $this->renderError($file->getError());
    }
}
